package com.jyx.chain;

import com.jyx.chain.filter.Filter;
import com.jyx.chain.filter.html.HtmlFilter;
import com.jyx.chain.filter.service.ServiceFilter;
import com.jyx.chain.filterchain.FilterChain;

public class MsgProcessor {

	Filter[] filters = {new HtmlFilter(),new ServiceFilter()};
	FilterChain fc = new FilterChain();

	/**
	 * 处理敏感字眼
	 * @return
	 */
	public String  process(){
		// 1.原始
		// process the html tag <>
		//String r = msg.replace('<', '[').replace('>', ']');
		// process the sensitive words
		//r = r.replace("被就业", "就业").replace("敏感", "");
		// 2.安插filterChain
//		String r = msg;
//		for (Filter f : filters) {
//			r = f.doFilter(r);
//		}
		msg = fc.doFilter(msg);
		return msg;
	}
	
	public FilterChain getFc() {
		return fc;
	}
	
	public void setFc(FilterChain fc) {
		this.fc = fc;
	}
	
	private String msg;
	
	public String getMsg(){
		return this.msg;
	}
	
	public void setMsg(String msg){
		this.msg = msg;
	}
}

